<template>
  <div>
    <van-nav-bar title="房屋管理">
      <template #left>
        <van-icon color="#fff" name="arrow-left" @click="$router.back()" />
      </template>
    </van-nav-bar>
    <div v-if="list.length">
      <my-list-item :row="item" v-for="item in list" :key="item.id"/>
    </div>
    <div class="box" v-else>
      还没有房源 <span @click="$router.push('/add')">快去发布</span>
    </div>
  </div>
</template>

<script>
import { getHouses } from '@/api/user.js'
import MyListItem from '@/components/MyListItem.vue'
import { Toast } from 'vant'
export default {
  components: { MyListItem },
  data () {
    return {
      list: []
    }
  },

  async created () {
    Toast.loading({
      message: '加载中...',
      forbidClick: true
    })
    try {
      const res = await getHouses()
      this.list = res.data.body
    } catch (_) {
      Toast.fail()
    }
  },

  methods: {

  }
}
</script>

<style scoped lang='less'>
.box{
  height: 200px;
  text-align: center;
  line-height: 200px;
  span{
    color: green;
  }
}
</style>
